$(window).ready(function(){
	var thisURL = window.location.href;

	function subjectIDSucFn(data){
		if(data.code == "0000"){
			var data =data.data;
			var postTime = data.postTime.substr(0,10);
			$(".news-title").text(data.subjectTitle);
			$(".news-infol").find("span").eq(0).text(postTime);
			$(".news-infol").find("span").eq(1).text(data.Author);
			$(".news-infor").find("span").text(data.ViewCount);
			var contents =data.Content.sections;
			for(var i=0;i<contents.length;i++){
				if(contents[i].image.length == 0 || contents[i].image[0] == ""){
					
				}else{
					for(var j=0;j<contents[i].image.length;j++){
						var img = $('<img src="http://ydche.com/media/mcimg/'+contents[i].image[j]+'"/>');
						img.appendTo(".news-content");
					}
				}
				if(contents[i].message == ""){
					
				}else{
					var text = $('<p>'+contents[i].message+'</p>');
					text.appendTo(".news-content");
				}
			}
		}else{
			alert("未找到文章！");
		}
	}

	if(thisURL.indexOf("?")>=0&&thisURL.indexOf("=")>=0){
		var  postId =thisURL.split('?')[1].split('=')[1];
		if(postId && postId !=""){
			var urlSubjectID = wxAddress+"/weixin/subject/text?subjectID="+postId;
			ajaxEncapsulation(urlSubjectID, subjectIDSucFn, "", "GET", "true");
		}
	}else{
		alert("已禁止本次访问：错误访问！");
		// 以下代码是用javascript强行关闭当前页面
		var opened = window.open("about:blank", "_self");
		opened.opener = null;
		opened.close();
	}
})